<?php
class hrd_hasil_tes_model extends MY_Model {
	var $nama_tabel = 'hrd_hasil_tes';
	
	function GetJSON($idpelamar) {
		$ls_sql	= "	SELECT	a.id_hasil_tes_pk, b.nama_materi_tes, TO_CHAR(a.tgl_tes,'DD/MM/YYYY') tgl_tes, a.id_materi_tes_fk, a.ket_hasil_tes, a.status_hasil_tes, to_char(nvl(a.hasil_tes,0),9999.99) hasil_tes
				FROM	".$this->nama_tabel." a
				LEFT JOIN hrd_materi_tes b ON a.id_materi_tes_fk = b.id_materi_tes_pk
				WHERE 	id_pelamar_fk = '".$idpelamar."'
				ORDER BY b.nama_materi_tes";

		// return json_encode( $this->paging($ls_sql) );
		$list = $this->db->query($ls_sql)->result_array();
		$data = array('total' => count($list), 'rows' => $list);
		return json_encode($data);
	}

	function Add($arr_data){
		$this->db->insert($this->nama_tabel, $arr_data);
	}

	function Update($arr_data, $arr_rule){
		$this->db->update($this->nama_tabel, $arr_data, $arr_rule);
	}

	function DeleteSingle($arr_rule) {
		try {
			$this->db->delete($this->nama_tabel, array('id_hasil_tes_pk' => $arr_rule['id_hasil_tes_pk']));
			return '';
		} catch(Exception $e) {
			return $e->getMessage();
		}
	}

}
?>